import { Component, OnInit } from '@angular/core';
import { Hero } from '../hero'
import { HeroService } from '../hero.service'
// import { MessageService } from '../message.service'

@Component({
  selector: 'app-heros',
  templateUrl: './heros.component.html',
  styleUrls: ['./heros.component.less']
})
export class HerosComponent implements OnInit {
  heroes: Hero[]
  // selectedHero:Hero
  constructor(
    private heroService: HeroService,
    // private messageService: MessageService
  ) { }

  ngOnInit(): void {
    this.getHeroes()
  }
  /**handleHeroClk(hero:Hero):void {
    console.log(hero)
    this.selectedHero = hero
    this.messageService.add(`HeroesComponent: Selected hero id=${hero.id}`);
  }*/
  getHeroes(): void {
    this.heroService.getHero().subscribe(heroes => this.heroes = heroes)
  }
}